<?php
/**
 * Created by PhpStorm.
 * User: kkw
 * Date: 2019/5/23
 * Time: 10:59
 */
namespace kkw\admin\response;
use kkw\admin\table\GoodsTypeTable;
use kkw\user\Util;
use suda\core\Request;
use suda\core\Response;

class deleteTypeResponse extends  Response
{
    public function onRequest(Request $request)
    {
        Util::printHeader();
        $json = Request::json();
        $id= $json['id'];
        $goodsType = new GoodsTypeTable();
        try {
            $goodsType->delete([id=>$id]);
        } catch (\suda\exception\SQLException $e) {
            $this->json(['code'=>$e->getCode(),'message'=> '删除数据失败']);
        }
        $this->json(['code'=>0,'message'=>'删除数据成功']);
    }
}